<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>res_edit.html</title>
</head>
 <body>
 <script type="text/javascript">
 	var winUnitEdit = new Windows("unit_edit");
 	$(function(){
 			winUnitEdit.find("#unitForm").form({
 				url:'$!basePath/admin/unit/doEdit',
 				onSubmit: function(){
			    	var pass = winUnitEdit.find('#unitForm').form("validate");
			    	if(pass){
			    		winUnitEdit.find("#ok").linkbutton("disable");
			    	}
			    	return pass; 
			    },   
			    success:function(data){
			   
			   		var result = jQuery.parseJSON(data);
			   		
			   		if(result.isEdited){
			        	top.Notiy.success("修改成功!");
			        	winUnitEdit.setReturnValue(true);
						winUnitEdit.close();
			        }else if(result.NoChanges){
			        	top.Notiy.info("您未做任何修改!");
			        	winUnitEdit.setReturnValue(true);
						winUnitEdit.close();			        	
			        }else{
			        	top.Dialog.alert("错误",result.error,"error");
			        }

			        winUnitEdit.find("#ok").linkbutton("enable");
			    }
 			});
 		});
	function ok(){
  		winUnitEdit.find('#unitForm').submit();
  	}
  	function cancel(){
  		winUnitEdit.setReturnValue(false);
  		winUnitEdit.close();
  	}
  	function unitTypeOnChange(n,o){
						 	winUnitEdit.find('#parentRes').combotree({   
    url: '$!basePath/admin/unit/unitTree?typeId='+n+'',   
    required: true
});

		var t=$('#parentRes').combotree('getValue');
			if(!isNaN(t)){
				$('#parentRes').combotree('setValue','请选择');
			}
		}
 </script>
 <div class="easyui-layout" data-options="fit:true">
	 <div data-options="region:'center',border:false" style="background:#fff;">
	 <form id="unitForm" method="post" style="padding-top:10px;padding-left: 20px;">
	 		<input type="hidden" name="id" value="$!unit.id"/>
					
				<table width="90%" >
			<tr>
					<td>机构类型：</td>
					<td>
						<select id="unitType" name="unitType.id" class="easyui-combotree" style="width: 193px;" data-options="url:'$!basePath/admin/unit/getunitTypeTree',animate:true,
						onChange:unitTypeOnChange">
							<option selected="selected" value="$!unit.unitType.id"></option> 
						</select>
					</td>
				</tr>
				<tr>
					<td>上级资源：</td>
					<td>
						<select id="parentRes" name="parentId" class="easyui-combotree" style="width: 193px;" data-options="url:'$!basePath/admin/unit/unitTree?typeId=$!unit.unitType.id',animate:true"  >
							 
							<option selected="selected" value="$!unitName.id"></option>
						</select>
					</td>
				</tr>
				<tr>
					<td>机构名称：</td>
					<td>
						<input type="text" class="easyui-validatebox" name="name" maxlength="50" data-options="required:true" style="width: 180px;" value="$!unit.name"/>
					</td>
				</tr>
				<tr>
					<td>机构编码：</td>
					<td>
						<input type="text" class="easyui-validatebox" name="code" maxlength="100" data-options="required:true" style="width: 180px;" value="$!unit.code"/>
					</td>
				</tr>
				<tr>
					<td>Email：</td>
					<td>
						<input type="text" class="easyui-validatebox" name="eMail" maxlength="50" data-options="validType:'email'" style="width: 180px;" value="$!unit.eMail"/>
					</td>
				</tr>
				<tr>
					<td>地址：</td>
					<td>
						<textarea rows="5" cols="21" name="address">$!unit.address</textarea>
					</td>
				</tr>
				<tr>
					<td>首页：</td>
					<td>
						<textarea rows="5" cols="21" name="web">$!unit.web</textarea>
					</td>
				</tr>
			</table>
		</form>
	 </div>
	 <div data-options="region:'south',border:false" style="text-align:center;padding:5px 0;">
		<a id="ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="ok()">确定</a>
		<a id="cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="cancel()">取消</a>
	</div>
 </div>
  </body>
</html>
